****
** Replication File:
**
** "Using an AI-powered ‘Street Epistemologist’ Chatbot 
** and Reflection Tasks to Diminish Conspiracy Theory Beliefs"
**
** Published in HKS Misinformation Review
**
** Marco Meyer, Adam Enders, Casey Klofstad, Justin Stoler and Joseph Uscinski
**
** Analyses executed in Stata/SE 15.1
****

set more off

* Set working directory!

* Open dataset
use "Spring 2024 Data.dta"

********************************************************************************

****
** Variable recoding and construction
****

* Gender
gen female = Q2 - 1


* Race
gen white = 0
replace white = 1 if Q3_1 == 1

gen black = 0
replace black = 1 if Q3_2 == 1

gen hispanic = Q4
recode hispanic (2=0)


* Income
gen income = Q5


* Education
gen edu = Q6


* Age
gen age = 2024 - Q7


* Conspiracy thinking
gen con1 = (CTSCALE_1 * -1) + 6
gen con2 = (CTSCALE_2 * -1) + 6
gen con3 = (CTSCALE_3 * -1) + 6
gen con4 = (CTSCALE_4 * -1) + 6

alpha con1-con4, gen(conthink)

********************************************************************************

* Pre-treatment CT belief
recode __js_recodeValue (42=11)
gen pre = __js_recodeValue - 1


* Post-treatment CT belief
gen post = Q366


* Drop those who did not agree or completely agreed
keep if pre >= 6 & pre <= 9


* Difference
gen diff = post - pre


* Belief importance
tab Importance


* Condition variables
gen group = "unknown"
replace group = "control1" if __js_questionName == "Spicy food is not only flavorful but also beneficial for metabolism."
replace group = "control2" if __js_questionName == "Locally sourced produce is fresher and more environmentally friendly than produce shipped from far away."
replace group = "control3" if __js_questionName == "Breakfast is the most important meal of the day and should not be skipped."
replace group = "treat1" if ! missing(Treatment1)
replace group = "treat2" if ! missing(TREATMENT2) & Control1 == .
replace group = "treat3" if ! missing(TREATMENT3)

drop if group == "unknown"

gen treat = .
replace treat = 0 if group == "control1" | group == "control2" | group == "control3"
replace treat = 1 if group == "treat1"
replace treat = 2 if group == "treat2"
replace treat = 3 if group == "treat3"

* Treatment 1 = reasons
gen treat1 = 0
replace treat1 = 1 if ! missing(Treatment1)

* Treatment 2 = reservations
gen treat2 = 0
replace treat2 = 1 if ! missing(TREATMENT2) & Control1 != .

* Treatment 3 = chatbot
gen treat3 = 0
replace treat3 = 1 if ! missing(TREATMENT3)

********************************************************************************

****
** Figure 1 (saved in "Effects.csv")
****

* Treatment effects
mean diff if treat == 0
mean diff if treat == 1
mean diff if treat == 2
mean diff if treat == 3

* Significant differences between pairs of effects?
reg diff i.treat
reg diff ib1.treat
reg diff ib2.treat
reg diff ib3.treat

* Cohen's d
summ diff if treat == 0
display =`r(mean)'/`r(sd)'

summ diff if treat == 1
display =`r(mean)'/`r(sd)'

summ diff if treat == 2
display =`r(mean)'/`r(sd)'

summ diff if treat == 3
display =`r(mean)'/`r(sd)'

****
** Figure 2 (saved in "Effects, Importance.csv")
****

reg diff i.treat##c.Importance

mean diff if treat == 0 & Importance > 3 & Importance < .
mean diff if treat == 1 & Importance > 3 & Importance < .
mean diff if treat == 2 & Importance > 3 & Importance < .
mean diff if treat == 3 & Importance > 3 & Importance < .

mean diff if treat == 0 & Importance < 3 
mean diff if treat == 1 & Importance < 3 
mean diff if treat == 2 & Importance < 3 
mean diff if treat == 3 & Importance < 3 

****
** Figure 3 (saved in "Effects, ACTS.csv")
****

reg diff i.treat##c.conthink


sum conthink, detail
mean diff if treat == 0 & conthink <= 2.75
mean diff if treat == 0 & conthink > 2.75 & conthink <= 4
mean diff if treat == 0 & conthink > 4 & conthink < .

mean diff if treat == 1 & conthink <= 2.75
mean diff if treat == 1 & conthink > 2.75 & conthink <= 4
mean diff if treat == 1 & conthink > 4 & conthink < .

mean diff if treat == 2 & conthink <= 2.75
mean diff if treat == 2 & conthink > 2.75 & conthink <= 4
mean diff if treat == 2 & conthink > 4 & conthink < .

mean diff if treat == 3 & conthink <= 2.75
mean diff if treat == 3 & conthink > 2.75 & conthink <= 4
mean diff if treat == 3 & conthink > 4 & conthink < .


xtile tercile = conthink, nq(3)

mean diff if treat == 0 & tercile == 1
mean diff if treat == 0 & tercile == 2
mean diff if treat == 0 & tercile == 3

mean diff if treat == 1 & tercile == 1
mean diff if treat == 1 & tercile == 2
mean diff if treat == 1 & tercile == 3

mean diff if treat == 2 & tercile == 1
mean diff if treat == 2 & tercile == 2
mean diff if treat == 2 & tercile == 3

mean diff if treat == 3 & tercile == 1
mean diff if treat == 3 & tercile == 2
mean diff if treat == 3 & tercile == 3

********************************************************************************

****
** Figure A1 (saved in "MFX.csv")
****

reg diff i.treat age edu female black hispanic
est store mod1

margins, at(treat=(0(1)3))

esttab mod1 using "Estimates 1.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: OLS coefficients with standard errors in parentheses)	

****
** Figure A2 (saved in "MFX, Importance.csv")
****

reg diff i.treat##c.Importance age edu female black hispanic
est store mod2

reg diff i.treat##c.Importance age edu female black hispanic
margins, at(Importance=(1(1)5) treat=(0)) post
margins, coefl
test _b[1bn._at] = _b[5._at]

reg diff i.treat##c.Importance age edu female black hispanic
margins, at(Importance=(1(1)5) treat=(1)) post
margins, coefl
test _b[1bn._at] = _b[5._at]

reg diff i.treat##c.Importance age edu female black hispanic
margins, at(Importance=(1(1)5) treat=(2)) post
margins, coefl
test _b[1bn._at] = _b[5._at]

reg diff i.treat##c.Importance age edu female black hispanic
margins, at(Importance=(1(1)5) treat=(3)) post
margins, coefl
test _b[1bn._at] = _b[5._at]

esttab mod2 using "Estimates 2.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: OLS coefficients with standard errors in parentheses)	


mean diff if treat == 0 & Importance == 1
mean diff if treat == 0 & Importance == 2
mean diff if treat == 0 & Importance == 3
mean diff if treat == 0 & Importance == 4
mean diff if treat == 0 & Importance == 5

mean diff if treat == 1 & Importance == 1
mean diff if treat == 1 & Importance == 2
mean diff if treat == 1 & Importance == 3
mean diff if treat == 1 & Importance == 4
mean diff if treat == 1 & Importance == 5

mean diff if treat == 2 & Importance == 1
mean diff if treat == 2 & Importance == 2
mean diff if treat == 2 & Importance == 3
mean diff if treat == 2 & Importance == 4
mean diff if treat == 2 & Importance == 5

mean diff if treat == 3 & Importance == 1
mean diff if treat == 3 & Importance == 2
mean diff if treat == 3 & Importance == 3
mean diff if treat == 3 & Importance == 4
mean diff if treat == 3 & Importance == 5

****
** Figure A3 (saved in "MFX, ACTS.csv")
****

reg diff i.treat##c.tercile age edu female black hispanic
est store mod3

reg diff i.treat##c.tercile age edu female black hispanic
margins, at(tercile=(1(1)3) treat=(0)) post
margins, coefl
test _b[1bn._at] = _b[3._at]

reg diff i.treat##c.tercile age edu female black hispanic
margins, at(tercile=(1(1)3) treat=(1)) post
margins, coefl
test _b[1bn._at] = _b[3._at]

reg diff i.treat##c.tercile age edu female black hispanic
margins, at(tercile=(1(1)3) treat=(2)) post
margins, coefl
test _b[1bn._at] = _b[3._at]

reg diff i.treat##c.tercile age edu female black hispanic
margins, at(tercile=(1(1)3) treat=(3)) post
margins, coefl
test _b[1bn._at] = _b[3._at]


esttab mod3 using "Estimates 3.rtf", ///
	cells(b(star fmt(3)) se(par fmt(3))) legend label ///
	varlabels(_cons Constant) stats(r2 N, fmt(3 0 1)) ///
	addnotes(Note: OLS coefficients with standard errors in parentheses)	

****
** Covariate balance (saved in "Balance.csv")
****

mean age if treat == 0
mean age if treat == 1
mean age if treat == 2
mean age if treat == 3

mean edu if treat == 0
mean edu if treat == 1
mean edu if treat == 2
mean edu if treat == 3

mean female if treat == 0
mean female if treat == 1
mean female if treat == 2
mean female if treat == 3

mean black if treat == 0
mean black if treat == 1
mean black if treat == 2
mean black if treat == 3

mean hispanic if treat == 0
mean hispanic if treat == 1
mean hispanic if treat == 2
mean hispanic if treat == 3
